from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session

# DATABASE_URL = "sqlite:///./test.db"  # 或者其他数据库 URL，如 PostgreSQL、MySQL 等
DATABASE_URL = "mysql+mysqldb://root:0558YinLe!341676@localhost:3306/bizili"

# 'check_same_thread' is an invalid keyword argument for connect()
# engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
engine = create_engine(DATABASE_URL, connect_args={}, echo=True)  # echo=True 打印sql
local_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)
# 创建绑定当前线程的session
scp_session = scoped_session(local_session)
